package com.qk.mapper;

import com.qk.entity.User;
import dto.UserDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {


    List<User> getUsers(UserDto userDto);

    @Insert("INSERT INTO user(username, password, name, phone, email, gender, status, dept_id, role_id, image, remark, create_time, update_time) " +
            "VALUES(#{username}, #{password}, #{name}, #{phone}, #{email}, #{gender}, #{status}, #{deptId}, #{roleId}, #{image}, #{remark}, #{createTime}, #{updateTime})")
    void insert(User user);


    void deleteById(List<Integer> id);

    @Select("Select id, username, password, name, phone, email, gender, status, dept_id, role_id, image, remark, create_time, update_time from user where id = #{id}")
    User getById(Integer id);


    void update(User user);
@Select("select * from user u , role r where u.role_id = r.id and u.status = 1 and r.label = #{roleLabel}")
    List<User> listByRole1(String roleLabel);
@Select("select u.* ,r.label role_label from user u left join role r on u.role_id = r.id where username = #{username}")
    User SelectByUsername(String username);
@Select("select * from user")
    List<User> listAll();
@Select("select * from user u ,dept d where u.dept_id = d.id and u.status = 1 and u.dept_id = #{deptId}")
    List<User> listByDept(Integer deptId);
}

